package com.basker.pisces.orm.statement;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class UpdateCommand extends WriteCommand {

    private FieldObject timestampFieldObject;

    public UpdateCommand(FieldObject pkFieldObject) {
        super(pkFieldObject);
    }

    @Override
    public Collection<FieldObject> getFields() {
        List<FieldObject> fields = new ArrayList<>(getUpdateFields());

        fields.add(this.getPkFieldObject());

        if (this.timestampFieldObject != null) {
            fields.add(this.timestampFieldObject);
        }

        return fields;
    }

    public FieldObject getTimestampFieldObject() {
        return timestampFieldObject;
    }

    public Collection<FieldObject> getUpdateFields() {
        return super.getFields();
    }

    public void setTimestampFieldObject(FieldObject timestampFieldObject) {
        this.timestampFieldObject = timestampFieldObject;
    }
}
